<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>财务中心</title>
	<link rel="stylesheet" href="css/weui.min.css" />
	<link rel="stylesheet" href="fonts/iconfont.css" />
	<link rel="stylesheet" href="fonts/qiheIC.css" />
	<link rel="stylesheet" href="js/swiper/css/swiper.min.css" />
	<link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="css/zhanghu.css" />
	<script src="js/jquery-2.2.3.min.js"></script>
</head>
<style>
	.weui-loadmore {
		width: 100%;
		height: 100%;
		font-size: 14px;
		text-align: center;
		position: absolute;
		background: #fff;
		z-index: 999;
		color: #fff;
		margin: 0px;
		line-height: 500px;
	}

	.weui-loading {
		width: 40px;
		height: 40px;
	}
</style>

<body ontouchstart>
	<div class="loading" style="display:none;">
		<div class="weui-loadmore">
			<i class="weui-loading"></i>
		</div>
	</div>
	<div class="weui-flex  financial-center">
	</div>
	<div class="weui-cells financial-center-property">
		<div class="financial-center-totle">
			<div class="financial-center-totle">
				<div class="totle-number">
					<span id="totalBalance">0</span>
					<img class="trogger" id="help-icon" src="./images/question.min.png"></div>
				<div class="totle-text">总余额</div>
			</div>
		</div>
		<div class="welfare-cash">
			<div class="welfare">
				<div class="welfare-number"><span id="welfare">0</span></div>
				<div class="welfare-text">福利金</div>
			</div>
			<div class="cash">
				<div class="welfare-number" id="cash">0</div>
				<div class="welfare-text">现金</div>
			</div>
		</div>
	</div>
	<div class="financial-center-content-wrapper">
		<div class="financial-center-content">
			<div class="weui-cells nav-zhanghu">
				<a href="chongzhi.html" class="weui-cell weui-cell_access">
					<div class="weui-cell__hd">
						<i class="iconfont icon-wxpay" style=' color:#ff5959'></i>
					</div>
					<div class="weui-cell__bd">在线充值</div>
					<div class="weui-cell__ft"></div>
				</a>
				<a href="mingxi.html" class="weui-cell weui-cell_access">
					<div class="weui-cell__hd">
						<i class="iconfont icon-tixian" style=' color:#feac5a'></i>
					</div>
					<div class="weui-cell__bd">消费明细</div>
					<div class="weui-cell__ft"></div>
				</a>

				<a href="rechargeRecord.html" class="weui-cell weui-cell_access">
					<div class="weui-cell__hd">
						<i class="iconfont icon-jilu" style=' color:#9259ff'></i>
					</div>
					<div class="weui-cell__bd">充值记录</div>
					<div class="weui-cell__ft"></div>
				</a>
				<a href="frozenCard.html" class="weui-cell weui-cell_access">
					<div class="weui-cell__hd">
						<i class="iconqiheIC-IC" style=' color:#9259ff; font-size: 16px;'>
							<span class="path1" style="font-size: 16px;"></span><span class="path2"></span><span class="path3"></span><span
							 class="path4"></span><span class="path5"></span>
						</i>
					</div>
					<div class="weui-cell__bd">IC卡挂失</div>
					<div class="weui-cell__ft"></div>
				</a>
			</div>
		</div>
	</div>
	<div class="popup">
		<div class="popup-content-bg"></div>
		<div class="popup-content">
			<div class="popup-title">
				<img src="./images/question.min.png" alt="" style="float:left;">
				<span class="close" style="float:right;  width:7px;
					height:7px;
					position: relative;
					top: -10px; color: #9F9F9F; font-size: 14px;">x</span>
			</div>
			<div id="text1">总金额为福利+现金</div>
			<div id="text2">福利金账户：为公司发放福利</div>
		</div>
	</div>

</body>
<script src="./api.js"></script>
<script>

	window.onload = function () {
		$('.loading').css('display', 'block');
		let api = getApi()
		let userinfo = JSON.parse(localStorage.getItem('wxUserInfo')).data
		let customerID = userinfo.customer.customerID

		//获取token
		let token = userinfo.token

		//获取 福利金 现金      总余额=福利金+现金
		function getAccountAmount() {
			fetch(api + '/customer/' + customerID, {
				method: "get",
				headers: {
					'Content-type': 'application/json',
					"Authorization": token
				}
			})
				.then(res => res.json())
				.then((data) => {
					$('.loading').css('display', 'none');
					// 福利金
					let welfare = data.data.welfare
					//现金
					let cash = data.data.cash
					//总余额
					let totalBalance = data.data.welfare + data.data.cash

					$('#cash').html(cash)
					$('#welfare').html(welfare)
					$('#totalBalance').html(totalBalance)

				}).catch((err) => {
					// window.location.href = './index.html'
				})
		}

		// 调用获取福利金 现金   
		getAccountAmount()

		//控制弹窗是否显示
		$('.trogger').click(function () {
			$('.popup').css('display', 'block')
		})
		$('.close').click(function () {
			$('.popup').css('display', 'none')
		})
	}
</script>

</html>